#include "mentalreport.h"
#include "ui_mentalreport.h"
#include "HRVPro/hrvdataprocess.h"
MentalReport::MentalReport(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MentalReport)
{
    ui->setupUi(this);
    ui->progressBar_Activity_report->setTextVisible(false);
    ui->progressBar_Ballance_report->setTextVisible(false);
    ui->progressBar_Emotion_report->setTextVisible(false);
    ui->progressBar_Fatigure_report->setTextVisible(false);
    ui->progressBar_Heart_report->setTextVisible(false);
    ui->progressBar_RegistPressure_report->setTextVisible(false);
    ui->progressBar_mental_report->setTextVisible(false);
    ui->progressBar_psi_report->setTextVisible(false);
}

MentalReport::~MentalReport()
{
    delete ui;
}
void MentalReport::setV(DataBeans dbs)
{
    ui->label_ID_V->setText(dbs.UserID);
    ui->label_Name_V->setText(dbs.UserName);
    ui->label_SexAge_V->setText(dbs.UserSex+"/"+dbs.UserAge);
    ui->label_MeasureTime_V->setText(dbs.MeasureTime);

    HRVDataProcess hrvdataPro;
    HRVIndex hi=hrvdataPro.Json2HRVData(dbs.hrvIndexResults);
    ui->label_MeanRR_V->setText(QString::number(hi.time.RR_mean,'f',1));
    ui->label_SDNN_V->setText(QString::number(hi.time.RR_SDNN,'f',1));
    ui->label_RMSSD_V->setText(QString::number(hi.time.RR_RMSSD,'f',1));
    ui->label_ApEn_V->setText(QString::number(hi.time.ApEn,'f',2));

    ui->label_TP_V->setText(QString::number(hi.freq.TP,'f',1));
    ui->label_LF_V->setText(QString::number(hi.freq.LF,'f',1));
    ui->label_HF_V->setText(QString::number(hi.freq.HF,'f',1));
    ui->label_LFHF_V->setText(QString::number(hi.freq.LFHF,'f',2));

    QChart *chart=mrpc.CreateLineChart_HRV();
    ui->widget_hrv->setChart(chart);
    ui->widget_hrv->setRenderHint(QPainter::Antialiasing, true);//设置无锯齿
    mrpc.setHRVData(hi.time.RR);

    QChart *chart_psd=mrpc.CreateLineChart_PSD();
    ui->widget__freq->setChart(chart_psd);
    ui->widget__freq->setRenderHint(QPainter::Antialiasing, true);//设置无锯齿
    mrpc.setPSDData(hi.freq.freq,hi.freq.psd);

    ui->progressBar_Activity_report->setValue(hi.mp.tpScore);
    ui->progressBar_Ballance_report->setValue(hi.mp.AnsScore);
    ui->progressBar_Emotion_report->setValue(hi.mp.EmotionScore);
    ui->progressBar_Fatigure_report->setValue(hi.mp.PsiScore);
    ui->progressBar_Heart_report->setValue(hi.mp.hfScore);
    ui->progressBar_RegistPressure_report->setValue(hi.mp.SdnnScore);
    ui->progressBar_mental_report->setValue(hi.mp.MsiScore);
    ui->progressBar_psi_report->setValue(hi.mp.PsiScore);



    ui->textEdit->setText(hi.MentalPressureResults+"\n\n"+hi.AnsResults+"\n\n"+hi.SLResults);
}
